package com.qst.util;


import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Eumenides.
 * @create 2021-05-24 10:14
 */
public class DataConverter implements Converter<String, Date> {

    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

    @Override
    public Date convert(String source) {
        if(source.length() == 0) {
            return null;
        }
        try {
            System.out.println(format.parse(source));
            return format.parse(source);
        } catch (ParseException e) {
            System.out.println(123);
            throw new RuntimeException(source + "类型转换失败");
        }
    }
}
